from locust import HttpUser, task, constant
import hashlib
import threading
import time

from locust import HttpUser, TaskSet, task, between

from locust import HttpUser, TaskSet, task, between


header = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
        }

class UserBehavior(TaskSet):

    @task
    def upload_height(self):
        url = r"https://wt-stg.zenggao.net/admin/parasol/public/api/height/upload"
        data = {
  "height": 80.8,
  "weight": 20.8,
  "bmi": 31.6,
  "qrcode": "wt_10944458_wt",
  "machineid": "X502206002",
  "scan_qrcode": "",
  "scan_machineid": "X502206002"
}
        response = self.client.post(url, json=data,headers=header)

        result = response.json()

        print(result)

    def on_start(self):
        # 在启动时立即执行请求
        self.upload_height()

class WebsiteUser(HttpUser):
    tasks = [UserBehavior]
    wait_time = between(0, 0)  # 将等待时间设置为0，确保请求几乎同时发出


'''

{
  "height": 80.8,      
  "weight": 20.8,      
  "bmi": 31.6,        
  "qrcode": "wt_10944374_wt",   
  "machineid": "X502206002",
  "scan_qrcode": "",
  "scan_machineid": "X502206002" 
  }
'''



# locust -f others/xxxxx.py --host=https://wt-stg.zenggao.net --web-host=127.0.0.1